package com.itheima.web;


import com.itheima.common.R;
import com.itheima.utils.SMSUtils;
import com.itheima.utils.ValidateCodeUtils;
import org.springframework.web.bind.annotation.GetMapping;

import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpSession;


@RestController
public class SmsController {

    @GetMapping("/sms")
    public R sendCode(String phone, HttpSession session) {

        //用工具类创建验证码
        String code = ValidateCodeUtils.generateValidateCode4String(4);

        //SMS工具类调用阿里云给指定的手机号发送验证码

        //SMSUtils.sendMessage("短信签名","短信模板",15270376689);

        System.out.println("生成的验证码" + code);

        session.setAttribute("code", code);

        return R.success(code);

    }

}
